package bio;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;

public class BioClient {
    public static void main(String[] args) {
        try (Socket socket = new Socket()) {
            socket.connect(new InetSocketAddress("localhost", 8080));

            BufferedOutputStream messageStream = new BufferedOutputStream(socket.getOutputStream());

            messageStream.write("hello sayno".getBytes());

            messageStream.flush();

            BufferedInputStream bufferedInputStream = new BufferedInputStream(socket.getInputStream());

            byte[] message = new byte[32];

            while (bufferedInputStream.read(message) != -1) {
                System.out.println(new String(message));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
